﻿/*
  原理是跨脚本通信，该脚本位于仓库ahk-scripts中
*/

#Include ..\baseHandle.ahk

#Include ..\..\_lib\Sender.ahk

class Toast extends BaseHandle {

  static Handle(parsed) {
    m := parsed.params.findIndex(v => v = 'm'), t := parsed.target * (m ? 60 : 1)
    r := Sender.SendStr('main.ahk', t '@' parsed.Extra.join(A_Space))
    return this.Done(r ? 'after ' parsed.target (m ? ' minutes.' : ' seconds.') : 'fail.', r, 'x')
  }

  static Echo() => '
  (
    toast 定时提示
    toast [-m] <period> <detail>
  )'

  static Spec() {
    return {
      cmd: 'toast',
      desc: '定时提示',
      format: 'toast [-m] <period> <detail>',
      params: [{
        name: 'm',
        desc: '单位为分钟'
      }],
      args: {
        desc: '等待的时间',
        isOptional: false,
        cacheable: false,
      },
      extra: {
        desc: '主题',
        isEnable: true,
      }
    }
  }
}
